package com.rocbrid.order.controller;

import com.rocbrid.common.R;
import com.rocbrid.order.bean.Order;
import com.rocbrid.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 创建订单
     *
     * @param userId
     * @param commodityCode
     * @param count
     * @return
     */
    @GetMapping("/create")
    public R create(@RequestParam("userId") String userId,
                    @RequestParam("commodityCode") String commodityCode,
                    @RequestParam("count") int count) {
        Order order = orderService.create(userId, commodityCode, count);
        return R.ok(order);
    }
}